home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / gtk-2.0 / gtk / gtkfilesystem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-04-25  |  15.0 KB  |  382 lines

  1. /* GTK - The GIMP Toolkit
  2.  * gtkfilesystem.h: Abstract file system interfaces
  3.  * Copyright (C) 2003, Red Hat, Inc.
  4.  *
  5.  * This library is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU Lesser General Public
  7.  * License as published by the Free Software Foundation; either
  8.  * version 2 of the License, or (at your option) any later version.
  9.  *
  10.  * This library is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  * Lesser General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU Lesser General Public
  16.  * License along with this library; if not, write to the
  17.  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18.  * Boston, MA 02111-1307, USA.
  19.  */
  20.  
  21. #ifndef __GTK_FILE_SYSTEM_H__
  22. #define __GTK_FILE_SYSTEM_H__
  23.  
  24. /* This is a "semi-private" header; it is meant only for
  25.  * alternate GtkFileChooser backend modules; no stability guarantees 
  26.  * are made at this point
  27.  */
  28. #ifndef GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
  29. #error "GtkFileSystem is not supported API for general use"
  30. #endif
  31.  
  32. #include <glib-object.h>
  33. #include <gtk/gtkwidget.h>    /* For icon handling */
  34.  
  35. G_BEGIN_DECLS
  36.  
  37. typedef gint64 GtkFileTime;
  38.  
  39. typedef struct _GtkFileFolder       GtkFileFolder;
  40. typedef struct _GtkFileFolderIface  GtkFileFolderIface;
  41. typedef struct _GtkFileInfo         GtkFileInfo;
  42. typedef struct _GtkFileSystem       GtkFileSystem;
  43. typedef struct _GtkFileSystemIface  GtkFileSystemIface;
  44. typedef struct _GtkFileSystemVolume GtkFileSystemVolume;
  45.  
  46. typedef struct _GtkFilePath        GtkFilePath;
  47.  
  48. /* Mask of information about a file, for monitoring and
  49.  * gtk_file_system_get_info()
  50.  */
  51. typedef enum {
  52.   GTK_FILE_INFO_DISPLAY_NAME      = 1 << 0,
  53.   GTK_FILE_INFO_IS_FOLDER         = 1 << 1,
  54.   GTK_FILE_INFO_IS_HIDDEN         = 1 << 2,
  55.   GTK_FILE_INFO_MIME_TYPE         = 1 << 3,
  56.   GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
  57.   GTK_FILE_INFO_SIZE              = 1 << 5,
  58.   GTK_FILE_INFO_ALL               = (1 << 6) - 1
  59. } GtkFileInfoType;
  60.  
  61. /* GError enumeration for GtkFileSystem
  62.  */
  63.  
  64. #define GTK_FILE_SYSTEM_ERROR (gtk_file_system_error_quark ())
  65.  
  66. typedef enum
  67. {
  68.   GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
  69.   GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
  70.   GTK_FILE_SYSTEM_ERROR_INVALID_URI,
  71.   GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
  72.   GTK_FILE_SYSTEM_ERROR_FAILED,
  73.   GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS
  74. } GtkFileSystemError;
  75.  
  76. GQuark     gtk_file_system_error_quark      (void);
  77.  
  78. /* Boxed-type for gtk_file_folder_get_info() results
  79.  */
  80. #define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
  81.  
  82. GType       gtk_file_info_get_type (void) G_GNUC_CONST; 
  83.  
  84. GtkFileInfo *gtk_file_info_new  (void);
  85. GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
  86. void         gtk_file_info_free (GtkFileInfo *info);
  87.  
  88.  
  89. G_CONST_RETURN gchar *gtk_file_info_get_display_name      (const GtkFileInfo *info);
  90. G_CONST_RETURN gchar *gtk_file_info_get_display_key       (const GtkFileInfo *info);
  91. void                  gtk_file_info_set_display_name      (GtkFileInfo       *info,
  92.                                const gchar       *display_name);
  93. gboolean              gtk_file_info_get_is_folder         (const GtkFileInfo *info);
  94. void                  gtk_file_info_set_is_folder         (GtkFileInfo       *info,
  95.                                gboolean           is_folder);
  96. gboolean              gtk_file_info_get_is_hidden         (const GtkFileInfo *info);
  97. void                  gtk_file_info_set_is_hidden         (GtkFileInfo       *info,
  98.                                gboolean           is_hidden);
  99. G_CONST_RETURN gchar *gtk_file_info_get_mime_type         (const GtkFileInfo *info);
  100. void                  gtk_file_info_set_mime_type         (GtkFileInfo       *info,
  101.                                const gchar       *mime_type);
  102. GtkFileTime           gtk_file_info_get_modification_time (const GtkFileInfo *info);
  103. void                  gtk_file_info_set_modification_time (GtkFileInfo       *info,
  104.                                GtkFileTime        modification_time);
  105. gint64                gtk_file_info_get_size              (const GtkFileInfo *info);
  106. void                  gtk_file_info_set_size              (GtkFileInfo       *info,
  107.                                gint64             size);
  108.  
  109. /* The base GtkFileSystem interface
  110.  */
  111. #define GTK_TYPE_FILE_SYSTEM             (gtk_file_system_get_type ())
  112. #define GTK_FILE_SYSTEM(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
  113. #define GTK_IS_FILE_SYSTEM(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
  114. #define GTK_FILE_SYSTEM_GET_IFACE(inst)  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
  115.  
  116. struct _GtkFileSystemIface
  117. {
  118.   GTypeInterface base_iface;
  119.  
  120.   /* Methods
  121.    */
  122.   GSList *              (*list_volumes)        (GtkFileSystem     *file_system);
  123.   GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem     *file_system,
  124.                         const GtkFilePath *path);
  125.  
  126.   GtkFileFolder *    (*get_folder)     (GtkFileSystem     *file_system,
  127.                     const GtkFilePath *path,
  128.                     GtkFileInfoType    types,
  129.                         GError           **error);
  130.   gboolean           (*create_folder)  (GtkFileSystem     *file_system,
  131.                     const GtkFilePath *path,
  132.                             GError           **error);
  133.  
  134.   /* Volumes
  135.    */
  136.   void          (*volume_free)             (GtkFileSystem        *file_system,
  137.                         GtkFileSystemVolume  *volume);
  138.   GtkFilePath * (*volume_get_base_path)    (GtkFileSystem        *file_system,
  139.                         GtkFileSystemVolume  *volume);
  140.   gboolean      (*volume_get_is_mounted)   (GtkFileSystem        *file_system,
  141.                         GtkFileSystemVolume  *volume);
  142.   gboolean      (*volume_mount)            (GtkFileSystem        *file_system, 
  143.                         GtkFileSystemVolume  *volume,
  144.                         GError              **error);
  145.   char *        (*volume_get_display_name) (GtkFileSystem        *file_system, 
  146.                         GtkFileSystemVolume  *volume);
  147.   GdkPixbuf *   (*volume_render_icon)      (GtkFileSystem        *file_system,
  148.                         GtkFileSystemVolume  *volume,
  149.                         GtkWidget            *widget,
  150.                         gint                  pixel_size,
  151.                         GError              **error);
  152.  
  153.   /* Path Manipulation
  154.    */
  155.   gboolean      (*get_parent)      (GtkFileSystem      *file_system,
  156.                     const GtkFilePath  *path,
  157.                     GtkFilePath       **parent,
  158.                     GError            **error);
  159.   GtkFilePath * (*make_path)        (GtkFileSystem     *file_system,
  160.                      const GtkFilePath *base_path,
  161.                      const gchar       *display_name,
  162.                      GError           **error);
  163.   gboolean      (*parse)            (GtkFileSystem     *file_system,
  164.                      const GtkFilePath *base_path,
  165.                      const gchar       *str,
  166.                      GtkFilePath      **folder,
  167.                      gchar            **file_part,
  168.                      GError           **error);
  169.   gchar *      (*path_to_uri)      (GtkFileSystem      *file_system,
  170.                     const GtkFilePath  *path);
  171.   gchar *      (*path_to_filename) (GtkFileSystem      *file_system,
  172.                     const GtkFilePath  *path);
  173.   GtkFilePath *(*uri_to_path)      (GtkFileSystem      *file_system,
  174.                     const gchar        *uri);
  175.   GtkFilePath *(*filename_to_path) (GtkFileSystem      *file_system,
  176.                     const gchar        *path);
  177.  
  178.   /* Icons 
  179.    */
  180.   GdkPixbuf *  (*render_icon)    (GtkFileSystem     *file_system,
  181.                   const GtkFilePath *path,
  182.                   GtkWidget         *widget,
  183.                   gint               pixel_size,
  184.                   GError           **error);
  185.  
  186.   /* Bookmarks 
  187.    */
  188.   gboolean       (*insert_bookmark)        (GtkFileSystem     *file_system,
  189.                         const GtkFilePath *path,
  190.                         gint               position,
  191.                         GError           **error);
  192.   gboolean       (*remove_bookmark)        (GtkFileSystem     *file_system,
  193.                         const GtkFilePath *path,
  194.                         GError           **error);
  195.   GSList *       (*list_bookmarks)         (GtkFileSystem     *file_system);
  196.  
  197.   /* Signals 
  198.    */
  199.   void (*volumes_changed)   (GtkFileSystem *file_system);
  200.   void (*bookmarks_changed) (GtkFileSystem *file_system);
  201.  
  202.   /* Bookmark labels 
  203.    */
  204.   gchar *        (*get_bookmark_label)     (GtkFileSystem     *file_system,
  205.                         const GtkFilePath *path);
  206.   void           (*set_bookmark_label)     (GtkFileSystem     *file_system,
  207.                         const GtkFilePath *path,
  208.                         const gchar       *label);
  209. };
  210.  
  211. GType             gtk_file_system_get_type       (void) G_GNUC_CONST;
  212.  
  213. GSList *          gtk_file_system_list_volumes   (GtkFileSystem     *file_system);
  214.  
  215. GtkFileSystemVolume *gtk_file_system_get_volume_for_path (GtkFileSystem     *file_system,
  216.                               const GtkFilePath *path);
  217.  
  218. void              gtk_file_system_volume_free             (GtkFileSystem        *file_system,
  219.                                GtkFileSystemVolume  *volume);
  220. GtkFilePath *     gtk_file_system_volume_get_base_path    (GtkFileSystem        *file_system,
  221.                                GtkFileSystemVolume  *volume);
  222. gboolean          gtk_file_system_volume_get_is_mounted   (GtkFileSystem        *file_system,
  223.                                GtkFileSystemVolume  *volume);
  224. gboolean          gtk_file_system_volume_mount            (GtkFileSystem        *file_system, 
  225.                                GtkFileSystemVolume  *volume,
  226.                                GError              **error);
  227. char *            gtk_file_system_volume_get_display_name (GtkFileSystem        *file_system, 
  228.                                GtkFileSystemVolume  *volume);
  229. GdkPixbuf *       gtk_file_system_volume_render_icon      (GtkFileSystem        *file_system,
  230.                                GtkFileSystemVolume  *volume,
  231.                                GtkWidget            *widget,
  232.                                gint                  pixel_size,
  233.                                GError              **error);
  234.  
  235. gboolean          gtk_file_system_get_parent     (GtkFileSystem     *file_system,
  236.                           const GtkFilePath *path,
  237.                           GtkFilePath      **parent,
  238.                           GError           **error);
  239. GtkFileFolder    *gtk_file_system_get_folder     (GtkFileSystem     *file_system,
  240.                           const GtkFilePath *path,
  241.                           GtkFileInfoType    types,
  242.                           GError           **error);
  243. gboolean          gtk_file_system_create_folder  (GtkFileSystem     *file_system,
  244.                           const GtkFilePath *path,
  245.                           GError           **error);
  246. GtkFilePath *     gtk_file_system_make_path      (GtkFileSystem     *file_system,
  247.                           const GtkFilePath *base_path,
  248.                           const gchar       *display_name,
  249.                           GError           **error);
  250. gboolean          gtk_file_system_parse          (GtkFileSystem     *file_system,
  251.                           const GtkFilePath *base_path,
  252.                           const gchar       *str,
  253.                           GtkFilePath      **folder,
  254.                           gchar            **file_part,
  255.                           GError           **error);
  256.  
  257. gchar *      gtk_file_system_path_to_uri      (GtkFileSystem     *file_system,
  258.                            const GtkFilePath *path);
  259. gchar *      gtk_file_system_path_to_filename (GtkFileSystem     *file_system,
  260.                            const GtkFilePath *path);
  261. GtkFilePath *gtk_file_system_uri_to_path      (GtkFileSystem     *file_system,
  262.                            const gchar       *uri);
  263. GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem     *file_system,
  264.                            const gchar       *filename);
  265.  
  266. gboolean     gtk_file_system_path_is_local    (GtkFileSystem     *filesystem,
  267.                            const GtkFilePath *path);
  268.  
  269. GdkPixbuf   *gtk_file_system_render_icon   (GtkFileSystem      *file_system,
  270.                         const GtkFilePath  *path,
  271.                         GtkWidget          *widget,
  272.                         gint                pixel_size,
  273.                         GError            **error);
  274.  
  275. gboolean gtk_file_system_insert_bookmark (GtkFileSystem     *file_system,
  276.                       const GtkFilePath *path,
  277.                       gint               position,
  278.                       GError           **error);
  279. gboolean gtk_file_system_remove_bookmark (GtkFileSystem     *file_system,
  280.                       const GtkFilePath *path,
  281.                       GError           **error);
  282. GSList  *gtk_file_system_list_bookmarks  (GtkFileSystem     *file_system);
  283.  
  284. gchar   *gtk_file_system_get_bookmark_label (GtkFileSystem     *file_system,
  285.                          const GtkFilePath *path);
  286. void     gtk_file_system_set_bookmark_label (GtkFileSystem     *file_system,
  287.                          const GtkFilePath *path,
  288.                          const gchar       *label);
  289.  
  290. /*
  291.  * Detailed information about a particular folder
  292.  */
  293. #define GTK_TYPE_FILE_FOLDER             (gtk_file_folder_get_type ())
  294. #define GTK_FILE_FOLDER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
  295. #define GTK_IS_FILE_FOLDER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
  296. #define GTK_FILE_FOLDER_GET_IFACE(inst)  (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
  297.  
  298. struct _GtkFileFolderIface
  299. {
  300.   GTypeInterface base_iface;
  301.  
  302.   /* Methods
  303.    */
  304.   GtkFileInfo *      (*get_info)       (GtkFileFolder     *folder,
  305.                     const GtkFilePath *path,
  306.                         GError           **error);
  307.   gboolean           (*list_children)  (GtkFileFolder     *folder,
  308.                         GSList           **children,
  309.                         GError           **error);
  310.  
  311.   /* ??? refresh() ??? */
  312.  
  313.   /* Signals
  314.    */
  315.   void (*deleted)       (GtkFileFolder *monitor);
  316.   void (*files_added)   (GtkFileFolder *monitor,
  317.              GSList        *paths);
  318.   void (*files_changed) (GtkFileFolder *monitor,
  319.              GSList        *paths);
  320.   void (*files_removed) (GtkFileFolder *monitor,
  321.              GSList        *paths);
  322.  
  323.   /* Method / signal */
  324.   gboolean (*is_finished_loading) (GtkFileFolder *folder);
  325.   void     (*finished_loading)    (GtkFileFolder *folder);
  326. };
  327.  
  328. GType        gtk_file_folder_get_type      (void) G_GNUC_CONST;
  329. gboolean     gtk_file_folder_list_children (GtkFileFolder      *folder,
  330.                         GSList            **children,
  331.                         GError            **error);
  332. GtkFileInfo *gtk_file_folder_get_info      (GtkFileFolder      *folder,
  333.                         const GtkFilePath  *path,
  334.                         GError            **error);
  335.  
  336. gboolean     gtk_file_folder_is_finished_loading (GtkFileFolder *folder);
  337.  
  338.  
  339. /* GtkFilePath */
  340. #define GTK_TYPE_FILE_PATH             (gtk_file_path_get_type ())
  341.  
  342. GType   gtk_file_path_get_type (void) G_GNUC_CONST;
  343. #ifdef __GNUC__
  344. #define gtk_file_path_new_dup(str) \
  345.  ({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
  346. #define gtk_file_path_new_steal(str) \
  347.  ({ gchar *__s = (str); (GtkFilePath *)__s; })
  348. #define gtk_file_path_get_string(path) \
  349.  ({ const GtkFilePath *__p = (path); (const gchar *)__p; })
  350. #define gtk_file_path_free(path) \
  351.  ({ GtkFilePath *__p = (path); g_free (__p); })
  352. #else /* __GNUC__ */
  353. #define gtk_file_path_new_dup(str)     ((GtkFilePath *)g_strdup(str))
  354. #define gtk_file_path_new_steal(str)   ((GtkFilePath *)(str))
  355. #define gtk_file_path_get_string(str) ((const gchar *)(str))
  356. #define gtk_file_path_free(path)       g_free (path)
  357. #endif/* __GNUC__ */
  358.  
  359. #define gtk_file_path_copy(path)       gtk_file_path_new_dup (gtk_file_path_get_string(path))
  360. #ifdef G_OS_WIN32
  361. int _gtk_file_system_win32_path_compare (const gchar *path1,
  362.                      const gchar *path2);
  363. #define gtk_file_path_compare(path1,path2) \
  364.   _gtk_file_system_win32_path_compare (gtk_file_path_get_string (path1), \
  365.                                    gtk_file_path_get_string (path2))
  366. #else
  367. #define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
  368.                            gtk_file_path_get_string (path2))
  369. #endif
  370.  
  371. GSList *gtk_file_paths_sort (GSList *paths);
  372. GSList *gtk_file_paths_copy (GSList *paths);
  373. void    gtk_file_paths_free (GSList *paths);
  374.  
  375. /* GtkFileSystem modules support */
  376.  
  377. GtkFileSystem  *_gtk_file_system_create (const char *file_system_name);
  378.  
  379. G_END_DECLS
  380.  
  381. #endif /* __GTK_FILE_SYSTEM_H__ */
  382.